var express = require('express');
var router = express.Router();
var path = require('path');
var query = require('./Database');
/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('Yshangjia', {});
});
router.post('/shop',async (req,res)=>{
    // console.log(req.body);
    let list = req.body;
    console.log(list);
    let rows = await query("select * from shop where id = "+ list.shopid);
    let prorows = await query("select * from product where shopid = "+ list.shopid);
    console.log('+++++++++++++++++++');
    console.log(rows);
    console.log(prorows);
    console.log('+++++++++++++++++++');
    let data = [{code:100},rows,prorows];
    res.send(data);
});
router.post('/history',async (req,res)=>{
    // console.log(req.body);
    let list = req.body;
    console.log(list);
    await query("insert into history values(null,"+list.userid+","+list.productid+","+list.checktime+",1)");
    console.log('+++++++++++++++++++');
    console.log('+++++++++++++++++++');
    let data = {code:100};
    res.send(data);
});
module.exports = router;